import request from "@/utils/request";
import { adminToken } from "@/utils/variable";
export const loginByPassword = data => {
    return new Promise((resolve, reject) => {
        request({
            url: "/common/api/login",
            method: "POST",
            data,
        })
            .then(res1 => {
                if (res1.code === 200) {
                    localStorage[adminToken] = res1.data.token;
                }
                resolve(res1);
            })
            .catch(err => {
                reject(err);
            });
    });
};
export const logout = () => {
    return request({
        url: "/common/api/logout",
        method: "POST",
    });
};
export const sendEmailCode = data => {
    return request({
        url: "/common/api/sendEmailCode",
        method: "POST",
        data,
    });
};
export const loginByEmailCode = data => {
    return new Promise((resolve, reject) => {
        request({
            url: "/common/api/loginByEmailCode",
            method: "POST",
            data,
        })
            .then(res1 => {
                if (res1.code === 200) {
                    localStorage[adminToken] = res1.data.token;
                }
                resolve(res1);
            })
            .catch(err => {
                reject(err);
            });
    });
};
export const getUserInfo = () => {
    return request({
        url: "/admin/api/info",
    });
};
